package day0720API;

import java.util.Arrays;

// String : matches(),  split(正则表达式), replace()
public class Test6 {
    public static void main(String[] args) {
        System.out.println("zhao@qq.com".split("@")[0]);
        System.out.println("zhao@qq.com".split("@")[1]);

        //String类的split():   用括号中的正则表达式切分字符串(结果是一个String数组)
        String str="hello world";
        String[] strings=str.split(" ");
        //用Arrays工具类的toString方法将数组元素连接为一个字符串打印
        System.out.println(Arrays.toString(strings));

        String str2="abc123def456ghi3";
        String[] strings2=str2.split("\\d+");
        System.out.println(Arrays.toString(strings2));

        //String类的replaceAll(正则，子字符串):   将某个字符串中符合正则表达式的部分替换为子字符串
        String str3="abc123def456ghi3";
        //abc.def.ghi.
        String str4=str3.replaceAll("\\d+",".");
        System.out.println(str4);
    }
}